<html>
  <head>
    <title>批量扫描临时存储数据列表</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<link href="style/css.css" rel="stylesheet" type="text/css" />
	<link href="../../css/general1.css" rel="stylesheet" type="text/css" />
	<link href="../../zephyr/css/paginator.css" rel="stylesheet" type="text/css" />
	<link href="../../zephyr/css/drift.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../../script/hiawardbpm.js"></script>
    <script type="text/javascript" src="../../script/prototype.js"></script>
    <script type="text/javascript" src="/vchzms-hiaward/dwr/engine.js"> </script>
	<script type="text/javascript" src="/vchzms-hiaward/dwr/util.js"> </script>
    <script type="text/javascript" src="/vchzms-hiaward/dwr/interface/Dao.js"></script>
	<script type="text/javascript" src="../../zephyr/js/Pager.js"></script>
  </head>
  <body onload="initImageServletUrl()">
    <div id="content"></div>
	<div id="pagingBar"></div>
	<button onclick="removeVoucherTemp()" class="btn1">删除</button>
	
	<!-- This is the lightbox content -->
	<div id="light" class="white_content">
		<p align="right"><a href = "javascript:void(0)" onclick = "closewin()">
		Close
		</a></p>
		<table width="869" border="0" >
		  <tr>
		    <td width="856" align="left"><img id="ticket" src="pic/s.gif" width="866" height="405"/></td>
		  </tr>
		  <tr>
		    <td align="left">&nbsp;</td>
		    </tr>
		</table>
	</div>
	<div id="fade" class="black_overlay"></div>
    <script type="text/javascript">
   	var rowSize = 20;
	var rowNum = 1;
	var totalResults;
	var imageServletUrl;
	
    /**
     * 显示table元素
     * @param {Object} pageNum 页数
     * @param {Object} pageSize 每页大小
     */
	function showTable(pageNum,pageSize) {
		var pagination = new Object();
		pagination.currentPages = pageNum;
		pagination.pageSize = pageSize;
		Dao.getVoucherTempData(pagination,function(data){
			var con="<table width='900' border='0' cellspacing='0' cellpadding='0' class='tablist1'><tr><td class='title2'><span>批量扫描临时存储数据列表</span></td></tr></table>" + 
				"<table width='900' border='0' cellspacing='0' cellpadding='0' class='tablist1'><tr class='font3'><th><input type='checkbox' name='all' onclick='checkall()'/></th><th><span>正面图像</span>" + 
				"</th><th><span>反面图像</span></th><th><span>日期</span></th><th><span>帐号</span></th><th><span>凭证号</span></th><th><span>金额</span></th><th><span>票据类型</span></th><th><span>交换号</span></th></tr>";
			for(var i=0;i<data.results.length;i++){
				//alert(data.results[i].fimgid);
				con+="<tr><td><input type='checkbox' name='accountItem' value='"+data.results[i].vchsid+"'/></td><td><a href=javascript:openwin('"+imageServletUrl+data.results[i].fimgid+"')>查看</a></td>"
					+"<td><a href=javascript:openwin('"+imageServletUrl+data.results[i].bimgid+"')>查看</a></td><td>"+data.results[i].vchdate+"&nbsp;</td><td>"
					+data.results[i].accno+"&nbsp;</td><td>"+data.results[i].vchno+"&nbsp;</td><td>"+data.results[i].amount+"&nbsp;</td><td>"+data.results[i].vchtype+"&nbsp;</td><td>"+data.results[i].exchno+"&nbsp;</td></tr>";
			}
			con+="</table>";
			document.getElementById('content').innerHTML=con;
			
			totalResults = data.totalResults;
			var pages = totalResults/rowSize;	
			if(pages > parseInt(pages)) {
				pages = parseInt(pages) + 1;
			}else {
				pages = parseInt(pages);
			}
			RenderPager(totalResults,pageNum,rowSize,pages,"pagingBar");
		});
	}
	
	showTable(rowNum,rowSize);
	
    /**
     * 删除VoucherTemp数据
     */
	function removeVoucherTemp() {
		
		var accItems = document.getElementsByName("accountItem");
		var items = $A(accItems);
		var vouTmpArray = new Array();
		items.each(function(item){
			if(item.checked) {
				var voucherTemp = new Object();
				voucherTemp.vchsid = item.value;
				vouTmpArray.push(voucherTemp);
			}
		});
		if (vouTmpArray.length == 0) {
			alert("请选择要删除数据。")
			return;
		}
		if (!confirm("确认删除？是－选择确定，否-选择取消")) {
			return;
		}
		Dao.deleteVoucherTemp(vouTmpArray);
		showTable(rowNum,rowSize);
	}
	
	/**
	 * 复选框点击触发事件
	 */
	function checkall() {
		var allItem = document.getElementsByName("all")[0];
		var accItems = document.getElementsByName("accountItem");
		var items = $A(accItems);
		if(allItem.checked) {
			items.each(function(item){
				item.checked = true;
			});
		}else {
			items.each(function(item){
				item.checked = false;
			});
		}
	}
	
	/**
	 * 打开窗口显示指定名称的图片
	 * @param {Object} img 图片名
	 */
	function openwin(img) {
		document.getElementById('ticket').src = img;
		document.getElementById('light').style.display='block';
		document.getElementById('fade').style.display='block';
		
	}
	
	/**
	 * 关闭窗口
	 */
	function closewin() {
		document.getElementById('ticket').src = "pic/s.gif";
		document.getElementById('light').style.display='none';
		document.getElementById('fade').style.display='none';
	}
	
	function initImageServletUrl() {
		Dao.getImageServletUrl(function(res){
			imageServletUrl = res;
		})
	}
	
   </script>
  </body>
</html>
